package com.tgq.demo.common;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

public class Md5Util {

    public static void main(String[] args) {
        // 16位自定义密码 必须为16位
        String key = "1!3+56/891=1112*";
        String Password="123456";
        // 生成密钥
        byte[] byteKey = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue(), key.getBytes()).getEncoded();
        SymmetricCrypto aes = SecureUtil.aes(byteKey);
        //加密
        String encryptData = aes.encryptBase64(Password);
        System.out.println("加密"+encryptData);
        // 解密
        String decryptData = aes.decryptStr(encryptData);
        System.out.println("解密"+decryptData);


    }

}
